<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <script src="js/jquery-3.7.1.js"></script>
</head>
<body>
用户名：<input type="text" name="name" id="name"></br>
密 码：<input type="password" name="pass" id="pass"></br>
<input type="button" value="登录" id="btn">
<span id="error"></span>
<script>
    $("#btn").click(function (){
        var uname = $("#name").val();
        var pas = $("#pass").val();

        $.ajax("index.do",{
            type:"post",
            data:{
                name:uname,
                pass:pas
            },
            success:function (data){
                if(data == "yes"){
                    localStorage.setItem("userName",uname);
                    location.href = "index-hao.html";
                }else{
                    $("#error").text(data)
                }
            }
        })
    })
</script>
</body>
</html>